using System;
using System.Collections;

namespace Slaks.VectorBasics.Comparators
{
	public class FrequencyComparer : IComparer
	{
		public int Compare(VectorItem x, VectorItem y)
		{
			if (x.Frequency > y.Frequency) return -1;
			else if (x.Frequency == y.Frequency) return 0;
			return 1;
		}

		public int Compare(object x, object y)
		{
			VectorItem xx = x as VectorItem;
			VectorItem yy = y as VectorItem;
			if (xx == null || yy == null) throw new ArgumentException("Object passed for comparison is not Vertex");
			return Compare(xx, yy);
		}
	}
}